import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import autoImport from 'unplugin-auto-import/vite'
import { fileURLToPath } from 'url'
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '')
  
  return {
    plugins: [
      react({
        babel: {
          plugins: [['babel-plugin-react-compiler']],
        },
      }),
      autoImport({
        imports: ['react', 'react-router'],
        dts: 'src/types/auto-imports.d.ts',

      }),
    ],
    resolve:{
      alias:{
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      }
    },
    server: {
      port: Number(env.VITE_PORT) || 5173,
      open: true,
    },
  }
})
